#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		int x;
		cin >> x;
		int count = 0;
		/*for (int i = 31; i >= 0; i--) {
			if ((x >> i) & 1 == 1) {
				count++;
			}
		}*/
		while (x) {
			count++;
			x = x & (x - 1);
		}
		cout << count << endl;
	}
	return 0;
}